<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<link rel="stylesheet" type="text/css" media="screen" href="css/core/spc.css">
<style>
    .input-group .state-error input {
        background: #fff0f0;
        border-color: #A90329
    }

    .input-group .state-success input {
        background: #f0fff0;
        border-color: #7DC27D
    }

    .input-param {
        height: 32px;
        padding: 6px 12px;
        font-size: 13px;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        border: 1px solid #ccc;
        width: 12%;
        border-radius: 1px;
    }

    .input-param:focus {
        border-color: #66afe9;
    }

    .input-param:-ms-input-placeholder {
        color: #999
    }
</style>

<section id="widget-grid" class="">
    <div id="searchbar" class="row" style="margin-top:-10px;">
        <div class="col-sm-12 padding-5">
            <div class="well padding-5 margin-bottom-0">

                <div id="alt_sb_searchAlert" class="alert alert-warning" style="display: none;">
                    <strong><i class="fa fa-exclamation-circle"></i> No condition, </strong>
                    <label id="warn-label"></label>
                </div>
                <div class="row padding-10 padding-bottom-0">
                    <div class="col-sm-3">
                        <div class="form-group">
                            <input style="width:100%" id="slt_sb_project" name="search_projectId"
                                   placeholder="<spring:message code='SPC_PROJECT'/>"/>
                            <input type="hidden" name="search_projectName" id="h_search_projectName"/>
                        </div>
                    </div>
                    <div class="col-sm-3">
                        <div class="form-group">
                            <input style="width:100%" id="slt_sb_dc" name="search_dcIds"
                                   placeholder="<spring:message code='DIMENSIONCHAIN'/>"/>
                            <input type="hidden" name="search_dcNames" id="h_search_dcNames"/>
                        </div>
                    </div>
                    <div class="col-sm-3"></div>
                    <div class="col-sm-3">
                        <div class="btn-group pull-right">
                            <a href="javascript:void(0)" class="btn btn-sm btn-primary" id="btn_sb_searchBtn"> <i
                                    class="fa fa-search"></i> <spring:message code='GLOBAL_BUTTON_SEARCH'/></a>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <div class="row">
        <article class="col-sm-12 sortable-grid ui-sortable">
            <div class="jarviswidget jarviswidget-sortable" id="wgt_itemData" data-widget-colorbutton="false"
                 data-widget-editbutton="false" data-widget-deletebutton="false" role="widget" style="">
                <header role="heading">
                    <h2><strong>DimensionChain Data</strong></h2>
                    <div class="jarviswidget-ctrls" role="menu">
                        <a href="javascript:void(0);" class="button-icon jarviswidget-toggle-btn" rel="tooltip" title=""
                           data-placement="bottom" data-original-title="Collapse"><i class="fa fa-minus "></i></a>
                        <a href="javascript:void(0);" class="button-icon jarviswidget-fullscreen-btn" rel="tooltip"
                           title="" data-placement="bottom" data-original-title="Fullscreen"><i
                                class="fa fa-expand "></i></a>
                    </div>

                    <span class="jarviswidget-loader"><i class="fa fa-refresh fa-spin"></i></span>


                    <div class="widget-toolbar" role="menu">
                        <button type="button" id="btn_tolerance_import" class="btn btn-primary" data-toggle="modal"
                                data-target="#dlg_tolerance_import" rel="tooltip" title="" data-placement="bottom"
                                data-original-title="Import data">Import
                        </button>
                        <button type="button" id="btn_tolerance_export" class="btn btn-warning" data-toggle="modal"
                                rel="tooltip" title="" data-placement="bottom" data-original-title="Export data" disabled="true">Export
                        </button>
                    </div>

                    <div class="widget-toolbar" role="menu">
                        <button type="button" class="btn btn-success" data-toggle="modal"
                           data-target="#dlg_tolerance_new">
                            <i class="fa  fa-plus"></i> <spring:message code='DC_NEW'/>
                        </button>
                    </div>

                </header>

                <!-- widget div-->
                <div role="content">
                    <!-- widget edit box -->
                    <div class="jarviswidget-editbox">
                    </div>
                    <!-- end widget edit box -->

                    <!-- Item content -->
                    <div class="well no-space no-padding">
                        <!-- content -->
                        <div class="padding-5 bg-info">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Summary<span> <i
                                    class="fa fa-angle-down"></i></span></a>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse in">
                            <div class="widget-body-toolbar padding-10 bg-color-white">
                                <div class="row">
                                    <div class="col-xs-9 col-sm-9 col-md-7 col-lg-7">
                                        <div>
                                             <span class="text"> USL:&nbsp;&nbsp;
                                                 <input class="input-param" type="text" id="tolerance_usl"
                                                        placeholder="USL" value="">
                                                            </span>&nbsp;&nbsp;&nbsp;&nbsp;

                                            <span class="text"> LSL:&nbsp;&nbsp;
                                               <input class="input-param" type="text" id="tolerance_lsl"
                                                      placeholder="LSL" value="">
                                            </span>&nbsp;&nbsp;&nbsp;&nbsp;

                                            <span class="text"> CalculateTimes:&nbsp;&nbsp;
                                                 <input class="input-param" type="text" id="tolerance_calculateTimes"
                                                        placeholder="Times" value="">
                                            </span>&nbsp;&nbsp;&nbsp;&nbsp;

                                            <button type="button" id="btn_runTolerance"
                                                    data-loading-text="<i class='fa fa-refresh fa-spin'></i> Loading..."
                                                    class="btn btn-primary ajax-refresh" disabled="true">
                                                Run
                                            </button>
                                        </div>
                                        &nbsp;<label id="param-label" class="ItemError"></label>
                                    </div>
                                    <div class="col-xs-3 col-sm-3 col-md-2 col-lg-2">
                                        <div style="height:32px;text-align:center;">
                                        <span class="text" style="line-height:32px"> Yeild:&nbsp;&nbsp;
                                            <label class="bg-color-lighten" id="spn_ndc_yeild">-%</label>
                                        </span>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-5 col-sm-5 col-md-5 col-lg-5">
                                        <div class="input-group" style="float:left">
                                            <input class="form-control" type="text" placeholder="Label"
                                                   id="toleranceItem_name"
                                                   name="item_name">

                                            <div class="input-group-btn">

                                                <button id="itemNameSubmit" type="button"
                                                        class="btn btn-default btn-primary" disabled="true">

                                                    <i class="fa fa-submit "></i> <spring:message
                                                        code='GLOBAL_BUTTON_ADD'/>
                                                </button>
                                            </div>
                                        </div>
                                        &nbsp;<label id="add-label" class="ItemError"></label>
                                    </div>
                                </div>
                            </div>
                            <table id="tbl_tolerance_item"
                                   class="table table-striped table-bordered table-hover has-tickbox"
                                   style="margin-top: 0px !important;" width="100%">
                                <thead>
                                <tr>
                                    <th style="width:5%;">Label</th>
                                    <th>Id</th>
                                    <th>Component Name</th>
                                    <th>Chain Type</th>
                                    <th>Transfer Coefficient</th>
                                    <th>Nominal(mm)</th>
                                    <th>Tolerance</th>
                                    <th>Minimum(mm)</th>
                                    <th>Maximum(mm)</th>
                                    <th>Mean(mm)</th>
                                    <th>Distribution</th>
                                    <th>Operate</th>
                                </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <!-- Chart content -->
                    <div id="wgt_chart" class="margin-top-10">
                        <div class="well no-space no-padding">
                            <div class="padding-5 bg-info">
                                <a>ND Chart</a>
                            </div>
                            <hr class="margin-top-0 margin-bottom-0 floating">
                            <div class="row no-space padding-10">
                                <div class="col-xs-12 col-sm-12 col-md-10 col-lg-10">
                                    <div class="padding-10">
                                        <div id="toleranceChart_NDC" class="" style="min-height:403px;"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <br>
                </div>
            </div>
            <!-- end widget div -->
        </article>
    </div>

    <!-- Create DimensionChain-->
    <div class="modal fade" id="dlg_tolerance_new" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title">Create DimensionChain</h4>
                </div>
                <div class="modal-body fuelux">
                    <div id="alt_tolerance_new_msgbar" class="alert alert-warning margin-bottom-10"
                         style="display:none; "><label id="create-label"></label></div>
                    <div class="step-content">
                        <div class="step-pane active">
                            <form id="create_dc" enctype="multipart/form-data" target="uploadf" method="post">
                                <input type='hidden' id="project_name" name='soltkey'/>
                                <div class="row">
                                    <div class="col-md-8">
                                        <div class="form-group">
                                            <label>Project</label>
                                            <div>
                                                <input style="width:100%" id="slt_tolerance_new_project"
                                                       name="projectId"/>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-8">
                                        <div class="form-group margin-top-0">
                                            <label>DimensionChain Name</label>
                                            <input type="text" class="form-control" id="slt_tolerance_new_name"
                                                   name="toleranceName" value="" placeholder="Name" style="width:100%;">
                                        </div>
                                    </div>

                                </div>
                            </form>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button id="btn_tolerance_new_submit" type="button" class="btn btn-primary"
                            data-loading-text="<i class='fa fa-refresh fa-spin'></i>  save...&nbsp;">
                        Save
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_tolerance_new_cancel">
                        <spring:message code="GLOBAL_BUTTON_CANCEL"/>
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>

    <!-- Modal Import-->
    <div class="modal fade" id="dlg_tolerance_import" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">DimensionChain Data Import </h4>
                </div>
                <div class="modal-body fuelux">
                    <div id="alt_tolerance_import_msgbar" class="alert alert-warning margin-bottom-10" style="display:none; "><spring:message code="DATAIMPORT_ERR_MSG"/></div>
                    <div class="row">
                        <div class="col-md-12">
                            <a href="#data/history" class="pull-right"> <spring:message code="DATAIMPORT_HISTORY"/> </a>
                        </div>
                    </div>
                    <hr class="margin-top-0 margin-bottom-10"/>
                    <div id="wzd_tolerance_import" class="wizard" style="display:none;">
                        <ul class="steps">
                            <li data-target="#step1" class="active">
                                <span class="badge badge-info">1</span>Step 1<span class="chevron"></span>
                            </li>
                            <li data-target="#step2">
                                <span class="badge">1</span>Step 1<span class="chevron"></span>
                            </li>
                            <li data-target="#step3">
                                <span class="badge">2</span>Step 2<span class="chevron"></span>
                            </li>
                        </ul>
                    </div>

                    <div class="step-content">
                        <div class="step-pane active" id="step1">
                            <form id="frm_tolerance_import" enctype="multipart/form-data" target="uploadf" method="post">
                                <input type='hidden' id="txt_tolerance_import_soltkey" name='soltkey'/>
                                <div class="row">
                                    <div class="col-md-8">
                                        <div class="form-group">
                                            <label>Project</label>
                                            <div>
                                                <input style="width:100%" id="slt_tolerance_import_project" name="projectId"/>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-8">
                                        <div class="form-group">
                                            <label>DimensionChain</label>
                                            <div>
                                                <input class="form-control" type="text" placeholder="<spring:message code='MENU_ANALYSIS_TOLERANCE'/>..."
                                                       id="slt_tolerance_import_dc" name="dcId">
                                                <%--<input style="width:100%" id="slt_tolerance_import_dc" name="dcId"/>--%>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <hr class="margin-top-10 margin-bottom-10"/>
                                <div class="row">
                                    <div class="col-md-8">
                                        <div>
                                            <label>Choose file</label>
                                            <input type="file" class="btn btn-default" id="fle_tolerance_import_file" name="file" style="width:100%;" multiple="multiple">
                                            <div id="div_tolerance_import_upload_files"></div>
                                        </div>
                                    </div>
                                </div>

                            </form>
                        </div>
                        <div class="step-pane" id="step2">

                        </div>
                        <div class="step-pane" id="step3">
                            <span id="spn_tolerance_import_operator">Importing DimensionChain Item Data...</span>
                            <div class="progress progress-xs">
                                <div id="spn_tolerance_import_processbar" role="progressbar" aria-valuenow="0"
                                     aria-valuemin="0" aria-valuemax="100" style="width: 0%;"
                                     class="progress-bar"></div>
                            </div>
                            <div>
                                Status: <span id="spn_tolerance_import_status"></span>
                            </div>
                            <div>
                                Time: <span id="spn_tolerance_import_time"></span>
                            </div>
                            <br>
                            Log:
                            <div class="well well-light well-clean" id="spn_tolerance_import_logArea"
                                 style="min-height:100px;overflow: auto;">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button id="btn_tolerance_import_submit" type="button" class="btn btn-primary"
                            data-loading-text="<i class='fa fa-refresh fa-spin'></i>  Importing...&nbsp;">
                        Start Import
                    </button>
                    <button id="btn_tolerance_import_gobackTo1" type="button" class="btn btn-primary" style="display: none;">
                        <i class="fa fa-reply"> Go Back</i>
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        <spring:message code="GLOBAL_BUTTON_CANCEL"/>
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>

    <iframe name="uploadf" style="display:none"></iframe>
</section>
<script src="js/core/business/analysis/tolerance/toleranceInit.js" type="text/javascript"></script>
